# coding:utf8
import sys

if __name__ == '__main__':
    # 读取所有行
    lines = sys.stdin.readlines()
    # 设置列表a，b
    a_list = []
    b_list = []
    for line in lines:
        line = line.strip()
        if len(a_list) > 0:
            b_list = line.split(',')
        else:
            a_list = line.split(',')
        if len(a_list) > 30 or len(b_list):
            break
    # a,b元素的差列表集
    sum_list = []
    for a in a_list:
        for b in b_list:
            c = a + b
            sum_list.append(c)
    # 结果值
    c = 0
    for i, j in enumerate(sum_list):
        if i == 0:
            c = j
            continue
        if abs((c + j)) < abs((c - j)):
            c = c + j
        else:
            c = c - j
    if c < 0:
        print(abs(c))
